package com.tianhao.luo.graph;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

/**
 * 图形工厂
 * @author tianhao.luo
 * @date 2019/12/19 10:17
 */
public class CircleFactory implements GraphFactory {

    private Circle circle;
    /**
     * 构造图形
     *
     * @param sides@return
     */
    @Override
    public Graph create(int... sides) {
        circle = new Circle();
        //构造圆的条件，只有一条边
        HashMap<Integer, List<Line>> circleParam = new HashMap<>(1);
        if (sides.length == 1) {
            Line line = new Line(sides[0]);
            circleParam.put(1, Collections.singletonList(line));
            circle.setMap(circleParam);
            return circle;
        }
        throw new RuntimeException("圆形只能有一条边");
    }

}
